import { defineStore } from 'pinia';
import store from '@/utils/localStore.ts'
export const useShieldStore = defineStore('shieldStore', {
    state: () => ({ 
        shieldList: store.getItem('shieldList') ? JSON.parse(store.getItem('shieldList')) : []
     }),
    getters: {
    },
    actions: {
        add(list = []){
            this.shieldList = list
            store.setItem('shieldList', JSON.stringify(list))
        }
    },
    // persist: {
    //     key: 'shieldStore',
    //     storage: localStorage,
    //     paths: ['shieldList'], // 只持久化 count 属性
    // }
})

export const useGroupStore = defineStore('groupStore', {
    state: () => ({ 
        groupList: store.getItem('groupList') ? JSON.parse(store.getItem('groupList')) : []
     }),
    getters: {
    },
    actions: {
        add(list = []){
            this.groupList = list
            store.setItem('groupList', JSON.stringify(list))
        }
    }
})

export const useUserStore = defineStore('userStore', {
    state: () => ({ 
        userList:  [],
        filterUserList: []
     }),
    getters: {
    },
    actions: {
        addUser(list:any = []){
            this.userList = list
        },
        addFilterUser(list:any = []){
            this.filterUserList = list
        }
    }
})

export const useTimingStore = defineStore('timingStore', {
    state: () => ({ 
        timingList:  [],
        timingShow: store.getItem('timingShow') ? store.getItem('timingShow') : '0'
     }),
    getters: {
    },
    actions: {
        addTimingList(list:any = []){
            this.timingList = list
        },
        updateTimingShow(val:any = '0'){
            this.timingShow = val
            store.setItem('timingShow', val)
        }
    }
})
